echo off 
setlocal
where cmake
if errorlevel 1 (
	echo cmake NOT FOUND.
	exit /B -1
)
echo cmake found
where conan
if errorlevel 1 (
	ECHO conan NOT FOUND.
	exit /B -1
)
ECHO conan found
where python
if errorlevel 1 (
	ECHO python NOT FOUND.
	exit /B -1
)
ECHO python found
:: 检查Python 版本,要求Python 3
python --version | findstr /C:"Python 3"
if errorlevel 1 (
	ECHO python 3 required.
	exit /B -1
)
set sh_folder=%~dp0
rem 删除最后的 '\'
set sh_folder=%sh_folder:~0,-1%
rem 定义编译的版本类型(Debug|Release)
set build_type=Debug
rem 如果输入参数1为"RELEASE"(不区分大小写)则编译RELEASE版本
if /I "%1" == "RELEASE" ( set build_type=Release)
if /I "%1" == "DEBUG" ( set build_type=Debug)
echo build_type=%build_type%
set build_folder=%sh_folder%\build\project.msvc
set install_prefix=%sh_folder%\release\myrpcclient_windows_vc_x86_64
pushd %sh_folder%

if exist %build_folder% rmdir %build_folder% /s/q
mkdir %build_folder%

conan install %sh_folder% ^
	-s build_type=%build_type% ^
	-s compiler="Visual Studio" ^
	-o boost:without_stacktrace=True ^
	-if %build_folder% ^
	--build missing || exit /B

pushd %build_folder%

conan build -pf %install_prefix% %sh_folder% || exit
conan package -pf %install_prefix% %sh_folder% || exit

popd
popd
endlocal